﻿using System.Security.Cryptography.X509Certificates;
using System.ServiceModel;
using Microsoft.Commerce.Proxy.TransactionService.v201001;
using System;

namespace TestWebApplication.CommerceTransaction.APIs
{
    public class CommerceTransactionGetPurchaseApi : CommerceTransactionApi
    {
        private GetPurchaseInput input;
        public GetPurchaseOutput output;

        private DateRange dateRange;
        private CallerInfo callerInfo;
        private Guid originalTrackingGuid;
        private string purchaseId;

        public CommerceTransactionGetPurchaseApi(BasicHttpBinding binding, EndpointAddress address, X509Certificate2 clientCert,
               DateRange dateRange, CallerInfo callerInfo, string purchaseId)
            : base(binding, address, clientCert)
        {
            
            this.callerInfo = callerInfo;
            this.dateRange = dateRange;
            this.purchaseId = purchaseId;
        }

        protected override AbstractResponse ExecuteInternal(TransactionServiceChannel channel)
        {
            this.output = channel.GetPurchase(input);

            return output;
        }

        public override void PrepareRequestData()
        {
            // prepare the create account input;
            this.input = new GetPurchaseInput()
            {
                DateRange = this.dateRange,
                CallerInfo = this.callerInfo,
                OriginalTrackingGuid = new Guid(),
                PurchaseId = this.purchaseId
            };
        }

        public override void PrepareResponseData()
        {


            return;
        }
    }
}
